package com.ysdz.tibetan.tibetanmini.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    // 配置文档信息

    /**
     * 封装接口文档信息
     * @return
     */
    @Bean
    public Docket getDocket(){

        // 指定文档界面信息  包括标题、版本等等
        ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
        apiInfoBuilder.title("《Tibetan-Shopping》")
                .description("项目后端规范说明")
                .version("1.0.0")
                .contact(new Contact("Rain", "www.ysdz.com", "1511502172@qq.com"));

        ApiInfo apiInfo = apiInfoBuilder.build();

        // 指定文档风格
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ysdz.tibetan.tibetanmini"))
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
//                .apis(RequestHandlerSelectors.basePackage("com.ysdz.tibetan.tibetanmini.shopping.controller"))
//                .apis(RequestHandlerSelectors.basePackage("com.ysdz.tibetan.tibetanmini.user.controller"))
                .paths(PathSelectors.any())
                .build();

        return docket;
    }

    // 配置接口信息

}
